package com.chuan.lambda;

//推导lambda表达式
public class TestLambda1 {
    //静态内部类
    static class DLike implements ILike{
        @Override
        public void lambda() {
            System.out.println("i don't like lambda");
        }
    }

    public static void main(String[] args) {
        ILike like = new Like();
        like.lambda();

        like = new DLike();
        like.lambda();

        //局部内部类
        like = new ILike(){
            @Override
            public void lambda() {
                System.out.println("i like lambda too");
            }
        };
        like.lambda();

        //lambda简化
        like = ()-> {
            System.out.println("i don't like lambda neither");
        };
        like.lambda();
    }
}
//函数式接口
interface ILike{
    void lambda();
}
//实现类
class Like implements ILike{
    @Override
    public void lambda() {
        System.out.println("i like lambda");
    }
}